import { request } from "@/utils/http";
import { Key } from "react";
import type {
  ReqGetHospitalSetResponse,
  HospitalSetItem,
} from "./model/hospitalSetTypes";
/**
 * 分页获取医院设置列表
 * @param page 当前页
 * @param limit 每页条数
 * @returns
 */
export const reqGetHospitalSet = (
  page: number,
  limit: number,
  hosname?: string,
  hoscode?: string
) => {
  return request.get<any, ReqGetHospitalSetResponse>(
    // path参数
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    // query 参数
    {
      params: {
        hosname,
        hoscode,
      },
    }
  );
};

/**
 * 批量删除医院设置
 * @param idList id列表
 * @returns null
 */
export const reqBatchRemove = (idList: Key[]) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: idList,
  });
};

/**
 * 添加医院设置
 * @param data 表单对象
 * @returns null
 */
export const reqAddHospitalSet = (data: HospitalSetItem) => {
  return request.post<any, null>(`/admin/hosp/hospitalSet/save`, data);
};

/**
 * 修改医院设置
 * @param data 表单对象
 * @returns null
 */
export const reqUpdateHospitalSet = (data: HospitalSetItem) => {
  return request.put<any, null>(`/admin/hosp/hospitalSet/update`, data);
};

/**
 * 删除医院设置
 * @param id 医院设置Id
 * @returns null
 */
export const reqRemoveHospitalSetById = (id:number) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
};


/**
 * 获取一条医院设置
 * @param id 医院设置Id
 * @returns HospitalSetItem
 */
export const reqGetHospitalSetById = (id:number) => {
  return request.get<any, HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`);
};